<!DOCTYPE html>
<html lang="en" id="ben">
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title></title>
 	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<link rel="stylesheet" type="text/css" th:href="@{/css/style.css}" />
	<script type="text/javascript" th:src="@{/script/jquery-1.8.2.min.js}"></script>
	<script type="text/javascript">
	 var _width = $(window).width();
		var _ziHao = 20 * (_width/320);
		if(_width < 641){
			$("#ben").css({"font-size":_ziHao + "px"})
		}
 	</script>
</head>
<body>
	<article class="htmleaf-container">
		<div id="clipArea"></div>
		<div class="foot-use">
			<div class="uploader1 blue">
				<input type="button" name="file" class="button" value="打开">
				<input id="file" type="file" accept="image/*" multiple  />
			</div>
			<button id="clipBtn">截取</button>
			<button id="exit">取消</button>
		</div>
		<div id="view"></div>
	</article>

	<script th:src="@{/script/iscroll-zoom.js}"></script>
	<script th:src="@{/script/hammer.js}"></script>
	<script th:src="@{/script/jquery.photoClip.js}"></script>
	<script>
	var obUrl = ''
	$("#clipArea").photoClip({
		width: 300,
		height: 300,
		file: "#file",
		view: "#view",
		ok: "#clipBtn",
		loadStart: function() {
			console.log("照片读取中");
		},
		loadComplete: function() {
			console.log("照片读取完成");
		},
		clipFinish: function(dataURL) {
			console.log(dataURL);//图片路径
		}
	});
	</script>
	<script>
	$(function(){
		$(".htmleaf-container").show();
		$("#clipBtn").click(function(){
			//console.log(imgsource);
			if(imgsource!=""){
				window.sessionStorage.setItem("userhead",imgsource);
				var imagedata = imgsource.split(',')[1];
				var user=JSON.parse(window.sessionStorage.getItem("user"));
				var userid=user.userid;
				 $.ajax({
					url:"http://localhost:8080/UserController/saveHead",
					 type:"post",
					 data : {'imagedata': imagedata , "userid" : userid},
					 dataType: 'text',
					 async: false,
					 success : function(data) {
						 if(data=="succuss"){
							 console.log("成功");
						 }else{
							 console.log("失败");
						 }
						 },error : function(data, status) {
				            console.log("后台异常");
				        }
					 });
			}
			
			
			window.location = "/ViewController/goUserPanel2";
			
		})
	});
	</script>



</body>
</html>